Skip to content

Conversation

@jinliu9508
Copy link
Contributor

@jinliu9508 jinliu9508 commented Jan 13, 2026

Description

One Line Summary

Add isDeviceStorageUnlocked check to avoid accessing user data before the device is unlocked on Android 7.0+, and end initialization early if device storage is locked.

Details

Motivation

This allows the SDK to avoid reading/writing user data too early (e.g., in boot receivers or early background services), and to avoid crashes with the inconsistent state.

Scope

Terminate the initialization early depends on user storage availability.

Testing

Unit testing

OPTIONAL - Explain unit tests added, if not clear in the code.

Manual testing

Tested on Emulator Pixel 9 API 35
Step to reproduce:

  1. Set a PIN for the device
  2. Modify AndroidManifest.xml
    <receiver android:name="com.onesignal.notifications.receivers.BootUpReceiver" android:exported="true" android:directBootAware="true"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.QUICKBOOT_POWERON" /> <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED"/> </intent-filter> </receiver>
  3. Run the app once
  4. Restart the device
  5. Before unlocking the phone, run the command to capture the log
    adb logcat | grep -E "(SharedPreferences|BootUpReceiver)"

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
    • If it is hard to explain how any codes changes are related to each other then it most likely needs to be more than one PR
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
    • Simplify with less code, followed by splitting up code into well named functions and variables, followed by adding comments to the code.
  • I have reviewed this PR myself, ensuring it meets each checklist item
    • WIP (Work In Progress) is ok, but explain what is still in progress and what you would like feedback on. Start the PR title with "WIP" to indicate this.

This change is Reviewable

@github-actions
Copy link
Contributor

📊 Diff Coverage Report

Diff Coverage Report

Threshold: 80%

Changed Files Coverage

  • ApplicationService.kt: 0/180 lines (0.0%)
    • ⚠️ Below threshold: 180 uncovered lines
  • OneSignalImp.kt: 60/259 lines (23.2%)
    • ⚠️ Below threshold: 199 uncovered lines

Overall Coverage

60/439 lines covered (13.7%)

❌ Coverage Check Failed

Files below 80% threshold:

  • ApplicationService.kt: 0.0% (180 uncovered lines)

  • OneSignalImp.kt: 23.2% (199 uncovered lines)

📥 View workflow run

@jinliu9508 jinliu9508 added the WIP Work In Progress label Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WIP Work In Progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants